public class ActivitiesTest {

	// Google calendar token: CN3rwLXMDxCK0O_UAw

//  http://bluehouse.lotus.com/activities/service/atom/descendants?activityNodeUuid=DD9G0A0503010D6DD2532DD042A6DC0000E7
//  http://bluehouse.lotus.com/activities/service/atom/activitynode?activityNodeUuid=DD9G0A0503010D6DD2532DD042A6DC0000E7
 
    private static AtomService activitiesService;
    private static ActivitiesClient ac; 
	private static String protocol = 'https';
	private static String lotusServer = 'bluehouseisv.lotus.com';
	private static String userName = 'davecarroll@mailinator.com';
	private static String userPassword = 'Hailey24';
	private static String activityUuid = '596G092106AA5EA3F1905B18C4833C000000';
 
	private static void setupConnection() {
		activitiesService = new AtomService(protocol, lotusServer, userName, userPassword, false);
		System.assertNotEquals(activitiesService, null, '\n\nActivitiesTest:setupConnection:[line 17] - activitiesService is null\n\n');
        ac = new ActivitiesClient(activitiesService);
        System.assertNotEquals(ac, null, '\n\nActivitiesTest:setupConnection:[line 19] - ac[ActivitiesClient] is null\n\n');
        
        
	} 


	private static AtomBase e;
 
 	public static void testSuite() {
 		activitiesService = new AtomService(protocol, lotusServer, userName, userPassword, false);    
        ac = new ActivitiesClient(activitiesService);
        BluehouseService bhs = ac.getActivityService();
        System.debug('\n\n' + 'Service: \n' + bhs);
        
		//Feed f = ac.getActivityByUuid(activityUuid);
		//f.toAPP();
		//ac.getActivityNodes(activityUuid);
		
		//System.debug(LoggingLevel.INFO, ac.createActivity('activity from test suite.'));
		
		//ac.createActivity(makeActivity());
		//ac.createActivity('test');
		//ac.createToDoItem(new ToDoEntry(), activityUuid);
		 
		//e = f.getEntries()[0];
		//ToDoEntry tde = new ToDoEntry();
		//tde.convertToTodo((ActivityEntry)e);
		
		//System.debug(LoggingLevel.INFO, e);
		//exerciseEntry();
		
		/*ac.getAuthors(e);  
		ac.getContributors(e);  
		ac.getFeed('/activities/service/atom2/activities');
		ac.getActivitiesByEmail(new List<String>{'davecarroll@mailinator.com'});
		ac.getActivitiesByEmail('davecarroll@mailinator.com');
		ac.getActivitiesBySearch('test');
		ac.getActivitiesByTag('test');
		ac.getLink('test', e);
		ac.getTags(e, null);*/
			
		//List<ActivityNode> nodes;
		//TodoEntry todo = new ToDoEntry();
		//todo.convertToToDo((ActivityEntry)f.getentries()[0]);
 	}
	public static void main() {
		setupConnection();

		ac.createActivity('test');
		return;
		
  		BluehouseService bhs = ac.getActivityService();
		System.assertNotEquals(activitiesService, null, '\n\nActivitiesTest:main:[line 25] - bhs[BluehouseService] is null\n\n');
		 
		Workspace dashboard = bhs.getWorkspaceByTitleStartsWith('Activity');
		System.assertNotEquals(activitiesService, null, '\n\nActivitiesTest:main:[line 28] - no dashboard workspace found by starts with\n\n');
		Workspace activityList = bhs.getWorkspaceByTitleStartsWith('Activities');
		System.assertNotEquals(activitiesService, null, '\n\nActivitiesTest:main:[line 30] - no activities workspace found by starts with\n\n');
		dashboard = bhs.getWorkspaceByContains('Activity');
		System.assertNotEquals(activitiesService, null, '\n\nActivitiesTest:main:[line 32] - no dashboard workspace found by contains\n\n');
		
		List<ActivityNode> activities;
  		System.debug(LoggingLevel.INFO, '\n\n BLUEHOUSE SERVICE: \n' + bhs +
  				'\n\t ' + bhs.getWorkspaceCount() + ' workspaces\n\t');
  		for (Workspace w : bhs.workspaces) {
  			System.debug(LoggingLevel.INFO, '\n\n WORKSPACE NAME: ' + w.getTitle() + '\n');
  		}
  		for (ServiceCollection sc : bhs.getAllCollections()) {
  			System.debug(LoggingLevel.INFO, '\n\nCOLLECTION NAME: \n\t' + sc.getTitle() + '\n');
  		}/*
  		// Get all the specific bluehouse activity related uris
  		System.debug(LoggingLevel.INFO, '\n\n Activities Uri: ' + bhs.getActivitiesUri());
  		System.debug(LoggingLevel.INFO, '\n\n Completed Activities Uri: ' + bhs.getCompletedActivitiesUri());
  		System.debug(LoggingLevel.INFO, '\n\n Tuned Out Activities Uri: ' + bhs.getTunedOutActivitiesUri());
  		System.debug(LoggingLevel.INFO, '\n\n Deleted Activities Uri: ' + bhs.getDeletedActivitiesUri());
  		System.debug(LoggingLevel.INFO, '\n\n Public Activities Uri: ' + bhs.getPublicActivitiesUri());
  		System.debug(LoggingLevel.INFO, '\n\n Everything Uri: ' + bhs.getEverythingUri());
  		System.debug(LoggingLevel.INFO, '\n\n Todo List Uri: ' + bhs.getToDosUri());
  		*/
  		// Get the current activities for this user
  		//Workspace ws = bhs.getWorkspaceByTitle('Activities');
  		//for (ServiceCollection c : ws.getCollections()) {
  			//exerciseCollection(c);
  			//System.debug(LoggingLevel.INFO, '\n\n Activity: ' + c.getTitle() + ' [' + c.getHref() + ']\n');
  			// Grab the activity details
  			//Feed aFeed = ac.getActivityByFQUri(c.getHref());
  			//Feed aFeed = ac.getActivityByFQUri('https://bluehouseisv.lotus.com/activities/service/atom2/activity?activityUuid=596G092106AA5EA3F1905B18C4833C000000');
  			
  			//System.debug(LoggingLevel.INFO, '\n\n The FEED: ' + aFeed + '\n');
  			//System.debug(LoggingLevel.INFO, '\n\n Activity: ' + aFeed.getTitle() + ' has ' + aFeed.totalResults + ' results.\n\tID: ' + aFeed.getid() + '\n');
  			//ActivityEntry ae = (ActivityEntry)aFeed.getEntries()[0];
			//System.debug(LoggingLevel.INFO, '\n\n\t ACTIVITYENTRY: ' + ae + '\n');
  			//System.debug(LoggingLevel.INFO, '\n\nActivity entry id: ' + aFeed.getUsableId());
  			//List<ToDoEntry> todos = ac.getTodos(aFeed.getUsableId());
  			List<ToDoEntry> todos = ac.getTodos('596G092106AA5EA3F1905B18C4833C000000');
  			for (ToDoEntry tde : todos) {
  				System.debug(LoggingLevel.WARN, '\n\n\t TODO: ' + tde.toAPP() + '\n');
  			}
  			System.debug(LoggingLevel.INFO, todos);
  			//break; 
  		//} 
	}
 		
 	private static void exerciseCollection(Collection c) {
 			
 	}
 		//ac.getActivityByUuid(activityUuid);
		
		//System.debug('*Get activity tagged with "bluehouse"*');
		//activities = activitiesClient.getActivitiesByTag('bluehouse');
		//for ( integer i = 0; i < activities.size(); i++ ) {
		//	ActivityNode activity = (ActivityNode) activities.get(i);
		//	System.debug(i + ': ' + activity);
		//} 
		
		
		//activities = activitiesClient.getActivitiesBySearch('Dave');
		//System.debug('\n\n*Get activity that ' + userId + ' is a member of*');
		//activities = activitiesClient.getActivitiesByEmail(userId);
		//for ( integer i = 0; i < activities.size(); i++ ) {
		//	ActivityNode activity = (ActivityNode) activities.get(i);
		//	System.debug(LoggingLevel.INFO, i + ': ' + activity.getTitle());
		//}	
		
		
		//String activityUuid = 'DD9G0A0503010D6DD2532DD042A6DC0000E7';
		//String activityUuid = '0CDG092106AAB54B8B1F4DCFCEA4C3000104';
		//System.debug('\n\nGet Activity\n' +  activitiesClient.getActivityByUuid(activityUuid));
		//activities = activitiesClient.getActivitiesByUuid(activityUuid);
		//for ( integer i = 0; i < activities.size(); i++ ) {
		//	ActivityNode activity = (ActivityNode) activities.get(i);
		//	System.debug(LoggingLevel.INFO, i + ': ' + activity.getTitle());
		//}	
		
		//activities = activitiesClient.getActivityNodes(activityUuid);
		
		
		//System.debug('\n\n*Create an activity with the title ' + activityTitle+'*');
		//Entry activity;
		//activity = activitiesClient.createActivity(activityTitle);
		//activity = activitiesClient.createActivity();
		//System.debug(LoggingLevel.INFO, '\n\n ACTIVITY ID: \n' + activity.extensions.get('activity').value + '\n\n');
		//Boolean result = activity != null;
		
		//if (result) {
		//	System.debug(LoggingLevel.INFO, 'Activity created successfully');
		//}
		//else{
		//	System.debug(LoggingLevel.INFO, 'Problem creating activity');
		//}
		
		//List<ActivityNode> myActs = activitiesClient.getActivitiesByTag('tag3');
		//Entry actEntry = activitiesClient.createTodoItem(myActs[0]);
		//if (actEntry != null) {
		//	System.debug(LoggingLevel.INFO, 'ToDo created successfully');
		//}
		//else{
		//	System.debug(LoggingLevel.INFO, 'Problem creating ToDo');
		//}
		 
		
}